package com.mini.cn.goods.exception;

import com.mini.cn.goods.controller.SupplyMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: fly
 * Date: 2022/11/19
 * Time: 18:18
 */
@ControllerAdvice
@Slf4j
public class GloablExceptionHandle {

    @ExceptionHandler(value = MiniGoodsException.class)
    @ResponseBody
    public SupplyMap handleMiniException(MiniGoodsException e) {
        log.error("handleMiniException:", e);
        SupplyMap supplyMap = new SupplyMap();
        supplyMap.setEorrInfo(Integer.parseInt(e.getCode()), e.getMsg());
        return supplyMap;
    }
}
